package client

import (
	"context"
	"github.com/micro/go-micro/v2/client"
	"github.com/micro/go-micro/v2/client/grpc"
	"kop/framework/wrapper"
	"kop/pb"
	"kop/pb/service"
)

var MaidService service.MaidService

func init() {

	var c = grpc.NewClient(client.Wrap(wrapper.ClientLogWrapper))
	_ = c.Init()

	//s.Init(test.Flags()...)

	MaidService = service.NewMaidService("go.micro.srv.captain", c)
}

func GetMaids(roleID int32) []*pb.Maid {

	var maids, err = MaidService.GetMaids(context.Background(), &service.RoleRequest{RoleID: roleID})
	if err != nil {
		panic(err)
	}

	return maids.Maids
}

func FriendMaids(roleID int32) []*pb.Maid {

	var maids, err = MaidService.FriendMaids(context.Background(), &service.RoleRequest{RoleID: roleID})
	if err != nil {
		panic(err)
	}

	return maids.Maids
}

func GetMaid(roleID, maidID int32) (*pb.Maid, error) {

	return MaidService.GetMaid(context.Background(), &service.DefaultRequest{RoleID: roleID, Value: maidID})
}

func Create(roleID, maidID int32) (*pb.Maid, error) {

	return MaidService.Create(context.Background(), &service.DefaultRequest{RoleID: roleID, Value: maidID})
}

func GetMaidDate(roleID int32) *pb.MaidDate {

	var maidDate, err = MaidService.GetMaidDate(context.Background(), &service.RoleRequest{RoleID: roleID})
	if err != nil {
		panic(err)
	}
	return maidDate
}

func SaveDate(maidDate *pb.MaidDate) {

	var resp, err = MaidService.SaveDate(context.Background(), maidDate)
	if err != nil {
		panic(err)
	}

	*maidDate = *resp
}

//func Drink(roleID int32) (*service.MaidDrinkResp, error) {
//
//	return MaidService.Drink(context.Background(), &service.RoleRequest{RoleID: roleID})
//}

//func ClassUp(roleID, maidID, class int32) (*pb.Maid, error) {
//
//	return MaidService.ClassUp(context.Background(), &service.MaidClassUpRequest{RoleID: roleID, MaidID: maidID, Class: class})
//}
//
//func SkillUp(roleID, maidID, skillIndex int32) (*pb.Maid, error) {
//
//	return MaidService.SkillUp(context.Background(), &service.MaidSkillUpRequest{RoleID: roleID, MaidID: maidID, SkillIndex: skillIndex})
//}
